<?php 
/***********************************************************************************************/
/* Author Widget
/***********************************************************************************************/

	class Author_Widget extends WP_Widget {
	
		public function __construct() {
			parent::__construct(
				'author_widget',
				'Redox Widget: Author Information',
				array('description' => __('Author Information', 'redox_localize'))
			); 
		}
		
		public function form($instance) {
			$defaults = array(
				'name' => 'John Hancock',
				'imageurl' => 'imageurl',
				'description' => '',
				

			);
			
			$instance = wp_parse_args((array) $instance, $defaults);
			
			?>
			
			<p>
				<label for="<?php echo $this->get_field_id('name') ?>"><?php _e('Name:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" value="<?php echo esc_attr($instance['name']); ?>" />
			</p>
			
			<p>
				<label for="<?php echo $this->get_field_id('imageurl') ?>"><?php _e('Image URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('imageurl'); ?>" name="<?php echo $this->get_field_name('imageurl'); ?>" value="<?php echo esc_attr($instance['imageurl']); ?>" />
			</p>

			<p>
				<label for="<?php echo $this->get_field_id('description') ?>"><?php _e('Description:', 'redox_localize'); ?></label>
				<textarea type="text" class="widefat" rows="10" cols="20" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo esc_attr($instance['description']); ?></textarea>
			</p>


			<?php
		}
		
		public function update($new_instance, $old_instance) {

			$instance = $old_instance;
			
			$instance['name'] = $new_instance['name'];

			$instance['description'] = $new_instance['description'];

			$instance['imageurl'] = $new_instance['imageurl'];



			return $instance;
		}
		
		public function widget($args, $instance) {
			extract($args);

			$name = $instance['name'];
			

			$description = $instance['description'];

			$imageurl = $instance['imageurl'];

			echo '<div class="widget author_information post">'; 

			if ($imageurl) { 
				echo '<div class="portrait">';
				echo '<img class="img-portrait" src="' . $imageurl . '">';
				
				echo '</div>';
			}

			if ($name) { 
				echo '<h3 class="widget-title author-widget-title">' . $name . '</h3>';
			}

			

			if ($description) { 
				echo '<div class="description">' . $description . '</div>';
			}
			

			echo '</div>'; 
						
		}
	}


	register_widget('Author_Widget');

?>